<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:composite="http://java.sun.com/jsf/composite"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">
	<c:set var="itemIndex" value="#{itemIndex+1}" />
	<c:forEach items="#{resources}" var="resource" varStatus="status">
		<f:selectItems value="#{resource.children}" var="item"
			itemValue="#{item.id}" itemLabel="#{item.name}" />

		<c:choose>
			<c:when
				test="#{resource.type == 'MENU' and resource.permissionResources.size() != 0}">
				<p:outputPanel rendered="#{!resource.disable}"
					class="p-col-12 p-md-6 ui-selectmanycheckbox"
					style="padding: 4px 5px 0 0;">

					<div class="card card-w-title" style="margin-bottom: 0px;">
						<h1>#{resource.name}</h1>
						<div class="p-grid">
							<p:outputPanel styleClass="p-col-4 p-md-2">
								<p:checkbox id="opts_#{resource.code}" styleClass="parent"
									widgetVar="opts_#{resource.code}" itemIndex="#{index}"
									for="#{forId}" onchange="Role.onSelectAll(this.id)" />
								<p:outputLabel for="opts_#{resource.code}"
									value="#{msg['framework']['all']}" />
								<c:set var="index" value="#{index+1}" />
							</p:outputPanel>
							<c:forEach items="#{resource.children}" var="premission">
								<f:selectItems value="#{resource.children}" var="item"
									itemValue="#{item.id}" itemLabel="#{item.name}" />
								<p:outputPanel styleClass="p-col-4 p-md-2"
									rendered="#{!premission.disable}">
									<p:checkbox id="opts_#{premission.code}" styleClass="chilren"
										itemIndex="#{itemIndex}" for="#{forId}"
										onchange="Role.onSelectOne(this.id)" />
									<p:outputLabel for="opts_#{premission.code}"
										value="#{premission.name}" />
									<c:set var="itemIndex" value="#{itemIndex+1}" />
								</p:outputPanel>
							</c:forEach>
						</div>
					</div>
				</p:outputPanel>
			</c:when>
			<c:otherwise>
				<ui:include src="permission_panel.xhtml">
					<ui:param name="resources" value="#{resource.children}"></ui:param>
					<ui:param name="forId" value="#{forId}"></ui:param>
				</ui:include>
			</c:otherwise>
		</c:choose>

	</c:forEach>

</ui:composition>